package nc.bs.arap.bdebtday.ace.rule;

import org.apache.commons.lang3.ArrayUtils;

import nc.impl.pubapp.pattern.rule.IRule;
import nc.vo.bd.meta.BatchOperateVO;
import nc.vo.pub.SuperVO;
import nc.vo.pubapp.AppContext;

public class DefaultValueRule implements IRule<BatchOperateVO>{

	@Override
	public void process(BatchOperateVO[] batchVOs) {
		for(BatchOperateVO batchVO : batchVOs) {
			Object[] addVOs =  batchVO.getAddObjs();
			Object[] uptVOs =  batchVO.getUpdObjs();
			
			if(!ArrayUtils.isEmpty(addVOs)){
				for(Object obj : addVOs){
					SuperVO temp = (SuperVO) obj;
					
					temp.setAttributeValue("creator", AppContext.getInstance().getPkUser());
					temp.setAttributeValue("creationtime", AppContext.getInstance().getServerTime());
				}
			}
			
			if(!ArrayUtils.isEmpty(uptVOs)){
				for(Object obj : uptVOs){
					SuperVO temp = (SuperVO) obj;
					temp.setAttributeValue("modifier", AppContext.getInstance().getPkUser());
					temp.setAttributeValue("modifiedtime", AppContext.getInstance().getServerTime());
				}
			}
		}
	}

}
